import {eventBus} from "../utils/eventBus.js"
Component({
	data: {
		selected: 0,
		color: "#7A7E83",
		selectedColor: "#3cc51f",
		list: []
	},
	attached() {},
	created() {
		
		eventBus.on('setTabbarList', (e) => this.setTabbarList(e))
		eventBus.on('setTabbarSelected', (e) => this.setTabbarSelected(e))
		eventBus.emit('setTabbarList')
		eventBus.emit('setTabbarSelected')
	},
	methods: {
		setTabbarList(e){
			this.setData({
				list: e || []
			})
		},
		setTabbarSelected(e){
			this.setData({
				selected: e || 0
			})
		},
		switchTab(e) {
			const data = e.currentTarget.dataset
			const url = data.path
			wx.switchTab({
				url
			})
			// this.setData({
			// 	list: data.index
			// })
			eventBus.emit('setTabbarSelected', data.index)
		}
	}
})